<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>系统演示 - 外卖平台</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
            color: white;
        }
        .container {
            max-width: 800px;
            margin: 0 auto;
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(20px);
            border-radius: 20px;
            padding: 30px;
            box-shadow: 0 25px 50px rgba(0,0,0,0.15);
        }
        h1 {
            text-align: center;
            margin-bottom: 30px;
            font-size: 2.5rem;
        }
        .demo-section {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 12px;
            padding: 20px;
            margin-bottom: 20px;
        }
        .demo-section h3 {
            margin-bottom: 15px;
            color: #fff;
        }
        .demo-btn {
            display: inline-block;
            padding: 12px 24px;
            background: rgba(255, 255, 255, 0.2);
            color: white;
            text-decoration: none;
            border-radius: 8px;
            margin: 5px;
            transition: all 0.3s ease;
            border: 1px solid rgba(255, 255, 255, 0.3);
        }
        .demo-btn:hover {
            background: rgba(255, 255, 255, 0.3);
            transform: translateY(-2px);
        }
        .info {
            background: rgba(255, 255, 255, 0.1);
            border-radius: 8px;
            padding: 15px;
            margin: 15px 0;
        }
        .info h4 {
            margin-bottom: 10px;
            color: #fff;
        }
        .info p {
            margin: 5px 0;
            opacity: 0.9;
        }
        .status {
            padding: 10px;
            border-radius: 8px;
            margin: 10px 0;
            text-align: center;
        }
        .status.success {
            background: rgba(40, 167, 69, 0.3);
            border: 1px solid rgba(40, 167, 69, 0.5);
        }
        .status.error {
            background: rgba(220, 53, 69, 0.3);
            border: 1px solid rgba(220, 53, 69, 0.5);
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>🎯 系统演示页面</h1>
        
        <div class="info">
            <h4>📋 使用说明</h4>
            <p>这是一个完全独立的外卖平台系统演示。</p>
            <p>所有功能都在本地运行，无需网络连接。</p>
        </div>
        
        <div class="demo-section">
            <h3>1. 页面访问</h3>
            <p>点击下面的按钮访问不同页面：</p>
            <a href="index.html" class="demo-btn">🏠 首页</a>
            <a href="auth.html" class="demo-btn">🔐 登录注册</a>
            <a href="home.html" class="demo-btn">🏠 主页面</a>
            <a href="dish-manage.html" class="demo-btn">🍽️ 菜品管理</a>
        </div>
        
        <div class="demo-section">
            <h3>2. 测试账号</h3>
            <div class="info">
                <h4>预设测试账号：</h4>
                <p><strong>用户账号：</strong> admin / 1234</p>
                <p><strong>商家账号：</strong> merchant1 / 1234</p>
                <p><strong>骑手账号：</strong> rider1 / 1234</p>
            </div>
        </div>
        
        <div class="demo-section">
            <h3>3. 功能测试</h3>
            <p>测试系统核心功能：</p>
            <button class="demo-btn" onclick="testLocalStorage()">💾 测试存储</button>
            <button class="demo-btn" onclick="testUserRegistration()">👤 测试注册</button>
            <button class="demo-btn" onclick="testUserLogin()">🔑 测试登录</button>
            <button class="demo-btn" onclick="clearAllData()">🗑️ 清除数据</button>
        </div>
        
        <div class="demo-section">
            <h3>4. 测试结果</h3>
            <div id="test-results"></div>
        </div>
        
        <div class="demo-section">
            <h3>5. 系统状态</h3>
            <div class="info">
                <h4>当前状态：</h4>
                <p><strong>当前时间：</strong><span id="current-time"></span></p>
                <p><strong>本地存储：</strong><span id="storage-status"></span></p>
                <p><strong>用户数据：</strong><span id="user-status"></span></p>
            </div>
        </div>
    </div>

    <script>
        // 显示当前时间
        function updateTime() {
            document.getElementById('current-time').textContent = new Date().toLocaleString();
        }
        
        // 检查本地存储状态
        function checkStorageStatus() {
            try {
                localStorage.setItem('test', 'test');
                localStorage.removeItem('test');
                document.getElementById('storage-status').textContent = '✅ 正常';
                document.getElementById('storage-status').style.color = '#28a745';
            } catch (e) {
                document.getElementById('storage-status').textContent = '❌ 不支持';
                document.getElementById('storage-status').style.color = '#dc3545';
            }
        }
        
        // 检查用户状态
        function checkUserStatus() {
            const currentUser = localStorage.getItem('currentUser');
            const users = localStorage.getItem('users');
            
            if (currentUser) {
                const user = JSON.parse(currentUser);
                document.getElementById('user-status').textContent = `✅ 已登录 (${user.username})`;
                document.getElementById('user-status').style.color = '#28a745';
            } else if (users) {
                const userList = JSON.parse(users);
                document.getElementById('user-status').textContent = `📝 有用户数据 (${userList.length}个用户)`;
                document.getElementById('user-status').style.color = '#ffc107';
            } else {
                document.getElementById('user-status').textContent = '❌ 无用户数据';
                document.getElementById('user-status').style.color = '#dc3545';
            }
        }
        
        // 测试本地存储
        function testLocalStorage() {
            try {
                const testData = { test: 'data', timestamp: Date.now() };
                localStorage.setItem('test-data', JSON.stringify(testData));
                const retrieved = JSON.parse(localStorage.getItem('test-data'));
                
                if (retrieved.test === 'data') {
                    showResult('本地存储测试', '✅ 成功', 'success');
                } else {
                    showResult('本地存储测试', '❌ 失败', 'error');
                }
            } catch (e) {
                showResult('本地存储测试', '❌ 错误: ' + e.message, 'error');
            }
        }
        
        // 测试用户注册
        function testUserRegistration() {
            try {
                const testUser = {
                    id: 999,
                    username: 'testuser' + Date.now(),
                    password: '1234',
                    phone: '13800138000',
                    email: 'test@test.com',
                    type: 'user',
                    name: '测试用户',
                    registerTime: new Date().toLocaleString()
                };
                
                let users = JSON.parse(localStorage.getItem('users') || '[]');
                users.push(testUser);
                localStorage.setItem('users', JSON.stringify(users));
                
                showResult('用户注册测试', '✅ 成功', 'success');
                checkUserStatus();
            } catch (e) {
                showResult('用户注册测试', '❌ 错误: ' + e.message, 'error');
            }
        }
        
        // 测试用户登录
        function testUserLogin() {
            try {
                const users = JSON.parse(localStorage.getItem('users') || '[]');
                if (users.length > 0) {
                    const testUser = users[0];
                    localStorage.setItem('currentUser', JSON.stringify(testUser));
                    showResult('用户登录测试', '✅ 成功', 'success');
                    checkUserStatus();
                } else {
                    showResult('用户登录测试', '❌ 没有用户数据', 'error');
                }
            } catch (e) {
                showResult('用户登录测试', '❌ 错误: ' + e.message, 'error');
            }
        }
        
        // 清除所有数据
        function clearAllData() {
            if (confirm('确定要清除所有数据吗？')) {
                localStorage.clear();
                showResult('数据清除', '✅ 完成', 'success');
                checkUserStatus();
            }
        }
        
        // 显示测试结果
        function showResult(testName, message, type) {
            const resultsDiv = document.getElementById('test-results');
            const resultDiv = document.createElement('div');
            resultDiv.className = `status ${type}`;
            resultDiv.innerHTML = `<strong>${testName}:</strong> ${message}`;
            resultsDiv.appendChild(resultDiv);
        }
        
        // 页面加载时初始化
        window.onload = function() {
            updateTime();
            checkStorageStatus();
            checkUserStatus();
            
            // 每秒更新时间
            setInterval(updateTime, 1000);
        };
    </script>
</body>
</html>
